// 初始化模板，正式工程请删除
export default {
  namespaced: true,
  state: {
    books: [],
    selectedIndex: -1
  },
  mutations: {
    getNextBookIndex (state, payload) {
      if (state.selectedIndex < state.books.length - 1) {
        state.selectedIndex = state.selectedIndex + 1
      } else {
        state.selectedIndex = 0
      }
    },
    setBooks (state, payload) {
      state.books = payload
    }
  },
  actions: {
    setBooks (context, orderData) {
      const books = [{
        name: 'vue.js 从入门到精通',
        publicDate: '2018-10-26',
        author: '尤雨溪'
      }, {
        name: 'Python编程 从入门到实践',
        publicDate: '2016-07-01',
        author: '袁国忠'
      },
      {
        name: '数学之美（第二版）',
        publicDate: '2014-11-01',
        author: '吴军'
      },
      {
        name: '鸟哥的Linux私房菜',
        publicDate: '2018-10-01',
        author: '鸟哥'
      },
      {
        name: 'Linux内核深度解析',
        publicDate: '2019-05-01',
        author: '余华兵 '
      }
      ]
      context.commit('setBooks', books)
    }
  }
}
